<!DESCRIPTION> This is a handy script that counts the words (or characters) entered into a textarea and limits it to 100 words or less (this can be changed). <!/DESCRIPTION>
<!CATEGORY>Forms<!/CATEGORY>
<!SCRIPT>
<!-- START OF SCRIPT -->
<!-- HOW TO INSTALL WORD COUNTER:
1. Copy code into the HEAD section of document
2. Put last coding into the BODY section of document -->
<!-- STEP ONE: Add code into HEAD section of document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var submitcount=0;
function checkSubmit() {
if (submitcount == 0)
{
submitcount++;
document.Surv.submit();
}
}
function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ") {wordcounter++} // Counts the spaces while ignoring double spaces, usually one in between each word.
if (wordcounter > 250) {field.value = field.value.substring(0, x);}
else {countfield.value = maxlimit - wordcounter;}
}
}
function textCounter(field, countfield, maxlimit) {
<font color="000000" size="2" face="verdana, helvetica, arial">In 100 <b>words</b> or less, why do you (or would you) like living on the coast?</font><font color="ff0000" size="2" face="verdana, helvetica, arial">*</font>
<font color="000000" size="2" face="verdana, helvetica, arial">In 100 <b>characters</b> or less, why do you (or would you) like living on the coast?</font><font color="ff0000" size="2" face="verdana, helvetica, arial">*</font>
2. Put last coding into the BODY section of document -->
<!-- STEP ONE: Add code into HEAD section of document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var submitcount=0;
function checkSubmit() {
if (submitcount == 0)
{
submitcount++;
document.Surv.submit();
}
}
function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ") {wordcounter++} // Counts the spaces while ignoring double spaces, usually one in between each word.
if (wordcounter > 250) {field.value = field.value.substring(0, x);}
else {countfield.value = maxlimit - wordcounter;}
}
}
function textCounter(field, countfield, maxlimit) {
<font color="000000" size="2" face="verdana, helvetica, arial">In 100 <b>words</b> or less, why do you (or would you) like living on the coast?</font><font color="ff0000" size="2" face="verdana, helvetica, arial">*</font>
<font color="000000" size="2" face="verdana, helvetica, arial">In 100 <b>characters</b> or less, why do you (or would you) like living on the coast?</font><font color="ff0000" size="2" face="verdana, helvetica, arial">*</font>